load("@fbsource//tools/build_defs:rust_binary.bzl", "rust_binary")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("sapling")

rust_library(
    name = "mkscratch",
    srcs = glob(
        ["src/**/*.rs"],
        exclude = ["src/main.rs"],
    ),
    autocargo = {
        "cargo_target_config": {
            "name": "mkscratch",
        },
        "cargo_toml_config": {
            "package": {
                "authors": ["Source Control Oncall oncall+source_control@xmail.facebook.com"],
                "name": "mkscratch",
            },
        },
    },
    deps = [
        "fbsource//third-party/rust:hex",
        "fbsource//third-party/rust:sha2",
    ],
)

rust_binary(
    name = "scratch",
    srcs = ["src/main.rs"],
    autocargo = {
        "cargo_target_config": {
            "name": "mkscratch",
        },
    },
    os_deps = [
        (
            "linux",
            [
                "fbsource//third-party/rust:libc",
            ],
        ),
        (
            "macos",
            [
                "fbsource//third-party/rust:libc",
            ],
        ),
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:clap-3",
        "fbsource//third-party/rust:dirs",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:toml",
        ":mkscratch",
        "//eden/scm/lib/identity:identity",
    ],
)
